<?php
// $Id: fhreqchart.themes.inc,v 1.1 2009-03-08 13:25:49 frank Exp $
/**
 * @file
 * Common themes for fhreqchart.
 *
 * Copyright 2009 Frank Heinley.
 *
 * This file is part of fhreqchart.
 *
 * fhreqchart is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * fhreqchart is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with fhreqchart.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Format the range selection form.
 *
 * @ingroup themeable
 */
function theme_fhreqchart_show_range($range) {
  $months = fhreqchart_month_list();
  if (!$range['m2']) {
    $output = t(' for !month !year', array('!month' => $months[$range['month']], '!year' => $range['year']));
  }
  else {
    $output = t(' from !m1 !y1 to !m2 !y2',
      array('!m1' => $months[$range['month']], '!m2' => $months[$range['m2']],
            '!y1' => $range['year'], '!y2' => $range['y2']));
  }
  return $output;
}

/**
 * Format the total number of requests display.
 *
 * @ingroup themeable
 */
function theme_fhreqchart_total($count) {
  if ($count == 0) {
    return t('There were no requests for this period.');
  }
  return format_plural($count, 'There was one request for this period.',
                               'There were @count requests for this period.');
}

/**
 * Format the display range.
 *
 * @ingroup themeable
 */ 
function theme_fhreqchart_form_range(&$form) {
  $row[] = t('Type');
  $row[] = drupal_render($form['type']);
  $row[] = drupal_render($form['month']);
  $row[] = drupal_render($form['year']);
  $row[] = t('to');
  $row[] = drupal_render($form['month2']);
  $row[] = drupal_render($form['year2']);
  $row[] = drupal_render($form['submit']);
  $caption = $form['caption']['#value'];
  $junk = drupal_render($form['caption']);
  $output[] = theme('table', NULL, array($row), array('class' => 'fhreqchart-range'), $caption );
  $output[] = drupal_render($form);
  return implode("\n", $output);
}

/**
 * Format the report header
 *
 * @ingroup themeable
 */ 
function theme_fhreqchart_report_header($title, &$range) {
  $output[] = '<div class="fhreqchart-reporthead">';
  $output[] = '<p>'. $title . theme('fhreqchart_show_range', $range) .'</p>';
  $output[] = '</div><!-- fhreqchart-reporthead -->';
  return implode("\n", $output);
}
